package com.sz.web.account.control;

import com.sz.web.account.entity.AccountFunction;
import com.sz.web.account.entity.AccountRole;
import com.sz.web.account.service.AccountFunctionService;
import com.sz.web.account.service.AccountRoleService;
import com.sz.web.common.pojo.ReturnPojo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 功能权限
 */
@RequestMapping(value = "/account")
@Controller
public class AccountFunctionController {

    @Resource
    AccountFunctionService accountFunctionService;

    /**
     * 查询所有功能权限
     * @return
     */
    @PostMapping(value = "/function/query")
    @ResponseBody
    public ReturnPojo functionQuery(){
        return accountFunctionService.functionQuery();
    }

    /**
     * 根据角色名称查询功能权限
     * @param accountRole
     * @return
     */
    @PostMapping(value = "/function/queryByRole")
    @ResponseBody
    public ReturnPojo functionQueryByRole(@RequestBody AccountRole accountRole){
        return accountFunctionService.functionQueryByRole(accountRole.getId());
    }

    /**
     * 更新功能权限
     * @param accountFunction
     * @return
     */
    @PostMapping(value = "/function/updateByUrl")
    @ResponseBody
    public ReturnPojo functionUpdateNameByUrl(@RequestBody AccountFunction accountFunction){
        return accountFunctionService.functionUpdateNameByUrl(accountFunction);
    }




}
